#include <stdlib.h>
#include <stdio.h>

#define N (1 << 25)

unsigned int n;

#define bucle(TYPE, K) {				\
	unsigned int i;					\
	TYPE total = 0;					\
							\
	srand(0); /* same initialization for all*/	\
	total = rand();					\
	for (i=0; i<n; i++)				\
	{						\
		total = total % K;			\
		total = total * K + total;		\
		total = total / K + total + i;		\
	}						\
	printf("%u\n", total);				\
}

#define OPERAND (1<<14) 		/* Until 1<<15 */

void versio1()
{
	bucle(unsigned int, OPERAND);
}

void versio2()
{
	bucle(int, OPERAND);
}

int k;

void versio3()
{
	bucle(unsigned int, k);
}

void versio4()
{
	bucle(int, k);
}

int main(int argc, char *argv[])
{
	if (argc > 1) n = atoi(argv[1]); else n = N;

	k = OPERAND;

	versio1();
	versio2();
	versio3();
	versio4();

	return 0;
}
